package ai.people.netmon.telegram.controller;

import ai.people.netmon.framework.domain.telegram.entity.BusinessType;
import ai.people.netmon.framework.domain.telegram.entity.CountryConfig;
import ai.people.netmon.framework.domain.telegram.entity.LanguageConfig;
import ai.people.netmon.framework.domain.telegram.entity.SysCountryRegion;
import ai.people.netmon.framework.model.response.ListResponse;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.telegram.service.ConfigInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 配置信息
 *
 * @author yuanqinglong
 * @date 2022/1/13 16:32
 */
@RestController
@RequestMapping("/config")
public class ConfigInfoController {


    @Autowired
    private ConfigInfoService configInfoServiceImpl;

    /**
     * 国家列表
     *
     * @return {@link Result}<{@link ListResponse}<{@link CountryConfig}>>
     */
    @GetMapping("/countryList")
    public Result<ListResponse<CountryConfig>> countryList() {
        List<CountryConfig> countryConfigs = configInfoServiceImpl.countryList();
        ListResponse<CountryConfig> builder = ListResponse.builder(countryConfigs);
        return ResultUtil.success(builder);
    }

    /**
     * 语言列表
     *
     * @return {@link Result}
     */
    @GetMapping("/languageList")
    public Result<ListResponse<LanguageConfig>> languageList() {
        List<LanguageConfig> languageConfigs = configInfoServiceImpl.languageList();
        return ResultUtil.success(ListResponse.builder(languageConfigs));
    }


    /**
     * 业务类型列表
     *
     * @return {@link Result}<{@link ListResponse}<{@link BusinessType}>>
     */
    @GetMapping("/businessTypeList")
    public Result<ListResponse<BusinessType>> businessTypeList() {
        List<BusinessType> businessTypes = configInfoServiceImpl.businessTypeList();
        ListResponse<BusinessType> builder = ListResponse.builder(businessTypes);
        return ResultUtil.success(builder);
    }

    /**
     * 业务国家列表
     *
     * @return {@link Result}<{@link ListResponse}<{@link SysCountryRegion}>>
     */
    @GetMapping("/countryRegion")
    public Result<ListResponse<SysCountryRegion>> countryRegionList() {
        List<SysCountryRegion> sysCountryRegions = configInfoServiceImpl.countryRegionList();
        ListResponse<SysCountryRegion> regionListResponse = ListResponse.builder(sysCountryRegions);
        return ResultUtil.success(regionListResponse);
    }


}
